<template>
  <mi-header></mi-header>
  <div class="order">
    <!-- 订单详情页头部 -->
    <div class="order-header">
      <div class="order-header-content">
        <p>
          <i class="el-icon-s-order" style="font-size: 30px;color: #ff6700;"></i>
          订单详情页
          <small>
            请谨防钓鱼链接或诈骗电话，
            <a href="//www.mi.com/service/buy/Avoid%20Fraud" target="_blank">了解更多&gt;</a>
          </small>
        </p>
      </div>
    </div>
    <!-- 订单详情页头部END -->
    <!-- 订单详情页单主要内容 -->
    <div class="order-content">
      <div class="content">
        <ul>
          <!-- 订单详情页表头 -->
          <li class="order-info">
            <div class="order-id">
              订单单号: {{orderDetail.orderId}}
            </div>
            <div class="order-time">联系客服</div>
            <div class="order-status" style="margin-left: 50px;">申请售后</div>
            <div class="order-time">创建时间: {{orderDetail.orderTime}}</div>
            <div class="order-status">订单状态: {{orderDetail.status}}</div>
          </li>
          <li class="header">
            <div class="pro-img"></div>
            <div class="pro-name">商品名称</div>
            <div class="pro-price">单价</div>
            <div class="pro-num">数量</div>
            <div class="pro-total">小计</div>
          </li>
          <!-- 订单详情页表头END -->

          <!-- 订单详情列表 -->
          <li class="product-list" v-for="(product,i) in orderDetail.goods" :key="i">
            <div class="pro-img">
              <router-link :to="{ path: '/goods/details', query: {productID:product.productId} }">
                <img :src="product.pic_urls" />
              </router-link>
            </div>
            <div class="pro-name">
              <router-link
                :to="{ path: '/goods/details', query: {productID:product.productId} }"
              >{{product.productName}}</router-link>
            </div>
            <div class="pro-price">{{product.productPrice}}元</div>
            <div class="pro-num">{{product.productNum}}</div>
            <div class="pro-total pro-total-in">{{product.productPrice*product.productNum}}元</div>
          </li>
        </ul>
        <div>
          <h3 style="margin-left: 25px;">收货信息</h3>
          <table style="margin-left: 25px;margin-top: 10px;">
            <tr>
              <th>姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：</th>
              <td>{{orderDetail.name}}</td>
            </tr>
            <tr>
              <th>联系电话：</th>
              <td>{{orderDetail.receiverMobile}}</td>
            </tr>
            <tr>
              <th>收货地址：</th>
              <td>{{orderDetail.receiverAddress}}</td>
            </tr>
          </table>
        </div>
        <div class="order-bar">
          <div class="order-bar-left">
            <span class="order-total">
              共
              <span class="order-total-num">{{orderDetail.totalNum}}</span> 件商品
            </span>
          </div>
          <div class="order-bar-right">
            <span>
              <span class="total-price-title">合计：</span>
              <span class="total-price">{{orderDetail.payPrice}}元</span>
            </span>
          </div>
          <!-- 订单详情列表END -->
        </div>
      </div>
      <div style="margin-top:-40px;"></div>
    </div>
    <!-- 订单详情页主要内容END -->
  </div>
  <mi-footer></mi-footer>
</template>

<script>
import MiFooter from '@/components/MiFooter'
import MiHeader from '@/components/MiHeader'
import axios from 'axios'
export default {
  name: 'order-detail',
  components: {
    MiFooter,
    MiHeader
  },
  data () {
    return {
      orderDetail: {
        id: 9507,
        orderId: '64081644567019507',
        orderTime: '2022-02-14 00:00:00',
        status: '已完成',
        payPrice: '14396',
        totalNum: '4',
        receiverMobile: '18905213698',
        name: '张三',
        receiverAddress: '上海市闵行区',
        goods: [
          {
            productId: 1,
            productName: 'Redmi K30',
            productNum: 2,
            pic_urls: 'https://cdn.cnbj0.fds.api.mi-img.com/b2c-shopapi-pms/pms_1621955784.84614979.jpg',
            productPrice: 1599
          },
          {
            productId: 12,
            productName: 'iphone13',
            productNum: 2,
            pic_urls: 'https://cdn.cnbj0.fds.api.mi-img.com/b2c-shopapi-pms/pms_1621955784.84614979.jpg',
            productPrice: 5599
          }
        ]
      }
    }
  },
  created () {
    this.getOrderDetail()
  },
  methods: {
    getOrderDetail () {
      // 获取订单数据
      axios.get('http://localhost:8088/order/getOrderDetail',
        {
          params: {
            orderNo: '944910251042275328',
            userId: 123
          }
        }).then(res => {
        if (res.data.code === '0') {
          this.orderDetail = res.data.data
        } else {
          alert(res.data.msg)
        }
      })
    }
  }
}
</script>

<style>
  * {
    list-style: none;
  }
  .order {
    background-color: #f5f5f5;
    padding-bottom: 20px;
  }
  /* 订单详情页头部CSS */
  .order .order-header {
    height: 64px;
    border-bottom: 2px solid #ff6700;
    background-color: #fff;
    margin-bottom: 20px;
  }
  .order .order-header .order-header-content {
    width: 1225px;
    margin: 0 auto;
  }
  .order .order-header p {
    font-size: 28px;
    line-height: 58px;
    float: left;
    font-weight: normal;
    color: #424242;
  }
  .order .order-header .order-header-content small {
    margin-left: 10px;
    font-size: 12px;
    line-height: 1.5;
    color: #757575;
  }
  /* 订单详情页头部CSS END */
  .order .content {
    width: 1225px;
    margin: 0 auto;
    background-color: #fff;
    margin-bottom: 50px;
  }

  .order .content ul {
    background-color: #fff;
    color: #424242;
    line-height: 85px;
  }
  /* 订单详情页表头CSS */
  .order .content ul .order-info {
    height: 60px;
    line-height: 60px;
    padding: 0 26px;
    color: #424242;
    border-bottom: 1px solid #ff6700;
  }
  .order .content ul .order-info .order-id {
    float: left;
    color: #ff6700;
  }
  .order .content ul .order-info .order-time {
    float: right;
  }
  .order .content ul .order-info .order-status {
    float: right;
    margin-right: 40px;
  }

  .order .content ul .header {
    height: 85px;
    padding-right: 26px;
    color: #424242;
  }
  /* 订单详情页表头CSS END */

  /* 订单列表CSS */
  .order .content ul .product-list {
    height: 85px;
    padding: 15px 26px 15px 0;
    border-top: 1px solid #e0e0e0;
  }
  .order .content ul .pro-img {
    float: left;
    height: 85px;
    width: 120px;
    padding-left: 80px;
  }
  .order .content ul .pro-img img {
    height: 80px;
    width: 80px;
  }
  .order .content ul .pro-name {
    float: left;
    width: 380px;
  }
  .order .content ul .pro-name a {
    color: #424242;
  }
  .order .content ul .pro-name a:hover {
    color: #ff6700;
  }
  .order .content ul .pro-price {
    float: left;
    width: 160px;
    padding-right: 18px;
    text-align: center;
  }
  .order .content ul .pro-num {
    float: left;
    width: 190px;
    text-align: center;
  }
  .order .content ul .pro-total {
    float: left;
    width: 160px;
    padding-right: 81px;
    text-align: right;
  }
  .order .content ul .pro-total-in {
    color: #ff6700;
  }

  .order .order-bar {
    width: 1185px;
    padding: 0 20px;
    border-top: 1px solid #ff6700;
    height: 50px;
    line-height: 50px;
    background-color: #fff;
  }
  .order .order-bar .order-bar-left {
    float: left;
  }
  .order .order-bar .order-bar-left .order-total {
    color: #757575;
  }
  .order .order-bar .order-bar-left .order-total-num {
    color: #ff6700;
  }
  .order .order-bar .order-bar-right {
    float: right;
  }
  .order .order-bar .order-bar-right .total-price-title {
    color: #ff6700;
    font-size: 14px;
  }
  .order .order-bar .order-bar-right .total-price {
    color: #ff6700;
    font-size: 30px;
  }
  /* 订单列表CSS END */
</style>
